Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
54fc8f0e
Commit
54fc8f0e
authored
Dec 24, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Internal: convert audio_output_command to strictly-typed enum
parent
2ea633a2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
47 deletions
+49
-47
Init.cxx
src/output/Init.cxx
+1
-1
Internal.hxx
src/output/Internal.hxx
+16
-16
OutputControl.cxx
src/output/OutputControl.cxx
+14
-12
OutputThread.cxx
src/output/OutputThread.cxx
+18
-18
No files found.
src/output/Init.cxx
View file @
54fc8f0e
...
...
@@ -58,7 +58,7 @@ AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin)
filter
(
nullptr
),
replay_gain_filter
(
nullptr
),
other_replay_gain_filter
(
nullptr
),
command
(
A
O_COMMAND_
NONE
)
command
(
A
udioOutputCommand
::
NONE
)
{
assert
(
plugin
.
finish
!=
nullptr
);
assert
(
plugin
.
open
!=
nullptr
);
...
...
src/output/Internal.hxx
View file @
54fc8f0e
...
...
@@ -40,29 +40,29 @@ struct config_param;
struct
PlayerControl
;
struct
AudioOutputPlugin
;
enum
audio_output_c
ommand
{
AO_COMMAND_NONE
=
0
,
AO_COMMAND_
ENABLE
,
AO_COMMAND_
DISABLE
,
AO_COMMAND_
OPEN
,
enum
class
AudioOutputC
ommand
{
NONE
,
ENABLE
,
DISABLE
,
OPEN
,
/**
* This command is invoked when the input audio format
* changes.
*/
AO_COMMAND_
REOPEN
,
REOPEN
,
AO_COMMAND_
CLOSE
,
AO_COMMAND_
PAUSE
,
CLOSE
,
PAUSE
,
/**
* Drains the internal (hardware) buffers of the device. This
* operation may take a while to complete.
*/
AO_COMMAND_
DRAIN
,
DRAIN
,
AO_COMMAND_
CANCEL
,
AO_COMMAND_
KILL
CANCEL
,
KILL
};
struct
AudioOutput
{
...
...
@@ -231,7 +231,7 @@ struct AudioOutput {
/**
* The next command to be performed by the output thread.
*/
enum
audio_output_c
ommand
command
;
AudioOutputC
ommand
command
;
/**
* The music pipe which provides music chunks to be played.
...
...
@@ -284,7 +284,7 @@ struct AudioOutput {
}
bool
IsCommandFinished
()
const
{
return
command
==
A
O_COMMAND_
NONE
;
return
command
==
A
udioOutputCommand
::
NONE
;
}
/**
...
...
@@ -299,7 +299,7 @@ struct AudioOutput {
*
* Caller must lock the mutex.
*/
void
CommandAsync
(
audio_output_c
ommand
cmd
);
void
CommandAsync
(
AudioOutputC
ommand
cmd
);
/**
* Sends a command to the #AudioOutput object and waits for
...
...
@@ -307,13 +307,13 @@ struct AudioOutput {
*
* Caller must lock the mutex.
*/
void
CommandWait
(
audio_output_c
ommand
cmd
);
void
CommandWait
(
AudioOutputC
ommand
cmd
);
/**
* Lock the #AudioOutput object and execute the command
* synchronously.
*/
void
LockCommandWait
(
audio_output_c
ommand
cmd
);
void
LockCommandWait
(
AudioOutputC
ommand
cmd
);
/**
* Enables the device.
...
...
src/output/OutputControl.cxx
View file @
54fc8f0e
...
...
@@ -46,7 +46,7 @@ AudioOutput::WaitForCommand()
}
void
AudioOutput
::
CommandAsync
(
audio_output_c
ommand
cmd
)
AudioOutput
::
CommandAsync
(
AudioOutputC
ommand
cmd
)
{
assert
(
IsCommandFinished
());
...
...
@@ -55,14 +55,14 @@ AudioOutput::CommandAsync(audio_output_command cmd)
}
void
AudioOutput
::
CommandWait
(
audio_output_c
ommand
cmd
)
AudioOutput
::
CommandWait
(
AudioOutputC
ommand
cmd
)
{
CommandAsync
(
cmd
);
WaitForCommand
();
}
void
AudioOutput
::
LockCommandWait
(
audio_output_c
ommand
cmd
)
AudioOutput
::
LockCommandWait
(
AudioOutputC
ommand
cmd
)
{
const
ScopeLock
protect
(
mutex
);
CommandWait
(
cmd
);
...
...
@@ -92,7 +92,7 @@ AudioOutput::LockEnableWait()
StartThread
();
}
LockCommandWait
(
A
O_COMMAND_
ENABLE
);
LockCommandWait
(
A
udioOutputCommand
::
ENABLE
);
}
void
...
...
@@ -109,7 +109,7 @@ AudioOutput::LockDisableWait()
return
;
}
LockCommandWait
(
A
O_COMMAND_
DISABLE
);
LockCommandWait
(
A
udioOutputCommand
::
DISABLE
);
}
inline
bool
...
...
@@ -134,7 +134,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
/* we're not using audio_output_cancel() here,
because that function is asynchronous */
CommandWait
(
A
O_COMMAND_
CANCEL
);
CommandWait
(
A
udioOutputCommand
::
CANCEL
);
}
return
true
;
...
...
@@ -148,7 +148,9 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
if
(
!
thread
.
IsDefined
())
StartThread
();
CommandWait
(
open
?
AO_COMMAND_REOPEN
:
AO_COMMAND_OPEN
);
CommandWait
(
open
?
AudioOutputCommand
::
REOPEN
:
AudioOutputCommand
::
OPEN
);
const
bool
open2
=
open
;
if
(
open2
&&
mixer
!=
nullptr
)
{
...
...
@@ -172,7 +174,7 @@ AudioOutput::CloseWait()
assert
(
!
open
||
!
fail_timer
.
IsDefined
());
if
(
open
)
CommandWait
(
A
O_COMMAND_
CLOSE
);
CommandWait
(
A
udioOutputCommand
::
CLOSE
);
else
fail_timer
.
Reset
();
}
...
...
@@ -219,7 +221,7 @@ AudioOutput::LockPauseAsync()
assert
(
allow_play
);
if
(
IsOpen
())
CommandAsync
(
A
O_COMMAND_
PAUSE
);
CommandAsync
(
A
udioOutputCommand
::
PAUSE
);
}
void
...
...
@@ -229,7 +231,7 @@ AudioOutput::LockDrainAsync()
assert
(
allow_play
);
if
(
IsOpen
())
CommandAsync
(
A
O_COMMAND_
DRAIN
);
CommandAsync
(
A
udioOutputCommand
::
DRAIN
);
}
void
...
...
@@ -239,7 +241,7 @@ AudioOutput::LockCancelAsync()
if
(
IsOpen
())
{
allow_play
=
false
;
CommandAsync
(
A
O_COMMAND_
CANCEL
);
CommandAsync
(
A
udioOutputCommand
::
CANCEL
);
}
}
...
...
@@ -277,7 +279,7 @@ AudioOutput::StopThread()
assert
(
thread
.
IsDefined
());
assert
(
allow_play
);
LockCommandWait
(
A
O_COMMAND_
KILL
);
LockCommandWait
(
A
udioOutputCommand
::
KILL
);
thread
.
Join
();
}
...
...
src/output/OutputThread.cxx
View file @
54fc8f0e
...
...
@@ -45,8 +45,8 @@
void
AudioOutput
::
CommandFinished
()
{
assert
(
command
!=
A
O_COMMAND_
NONE
);
command
=
A
O_COMMAND_
NONE
;
assert
(
command
!=
A
udioOutputCommand
::
NONE
);
command
=
A
udioOutputCommand
::
NONE
;
mutex
.
unlock
();
audio_output_client_notify
.
Signal
();
...
...
@@ -342,7 +342,7 @@ AudioOutput::WaitForDelay()
(
void
)
cond
.
timed_wait
(
mutex
,
delay
);
if
(
command
!=
A
O_COMMAND_
NONE
)
if
(
command
!=
A
udioOutputCommand
::
NONE
)
return
false
;
}
}
...
...
@@ -471,7 +471,7 @@ AudioOutput::PlayChunk(const MusicChunk *chunk)
Error
error
;
while
(
!
data
.
IsEmpty
()
&&
command
==
A
O_COMMAND_
NONE
)
{
while
(
!
data
.
IsEmpty
()
&&
command
==
A
udioOutputCommand
::
NONE
)
{
if
(
!
WaitForDelay
())
break
;
...
...
@@ -529,7 +529,7 @@ AudioOutput::Play()
assert
(
!
in_playback_loop
);
in_playback_loop
=
true
;
while
(
chunk
!=
nullptr
&&
command
==
A
O_COMMAND_
NONE
)
{
while
(
chunk
!=
nullptr
&&
command
==
A
udioOutputCommand
::
NONE
)
{
assert
(
!
current_chunk_finished
);
current_chunk
=
chunk
;
...
...
@@ -577,7 +577,7 @@ AudioOutput::Pause()
Close
(
false
);
break
;
}
}
while
(
command
==
A
O_COMMAND_
NONE
);
}
while
(
command
==
A
udioOutputCommand
::
NONE
);
pause
=
false
;
}
...
...
@@ -594,30 +594,30 @@ AudioOutput::Task()
while
(
1
)
{
switch
(
command
)
{
case
A
O_COMMAND_
NONE
:
case
A
udioOutputCommand
:
:
NONE
:
break
;
case
A
O_COMMAND_
ENABLE
:
case
A
udioOutputCommand
:
:
ENABLE
:
Enable
();
CommandFinished
();
break
;
case
A
O_COMMAND_
DISABLE
:
case
A
udioOutputCommand
:
:
DISABLE
:
Disable
();
CommandFinished
();
break
;
case
A
O_COMMAND_
OPEN
:
case
A
udioOutputCommand
:
:
OPEN
:
Open
();
CommandFinished
();
break
;
case
A
O_COMMAND_
REOPEN
:
case
A
udioOutputCommand
:
:
REOPEN
:
Reopen
();
CommandFinished
();
break
;
case
A
O_COMMAND_
CLOSE
:
case
A
udioOutputCommand
:
:
CLOSE
:
assert
(
open
);
assert
(
pipe
!=
nullptr
);
...
...
@@ -625,7 +625,7 @@ AudioOutput::Task()
CommandFinished
();
break
;
case
A
O_COMMAND_
PAUSE
:
case
A
udioOutputCommand
:
:
PAUSE
:
if
(
!
open
)
{
/* the output has failed after
audio_output_all_pause() has
...
...
@@ -642,7 +642,7 @@ AudioOutput::Task()
the new command first */
continue
;
case
A
O_COMMAND_
DRAIN
:
case
A
udioOutputCommand
:
:
DRAIN
:
if
(
open
)
{
assert
(
current_chunk
==
nullptr
);
assert
(
pipe
->
Peek
()
==
nullptr
);
...
...
@@ -655,7 +655,7 @@ AudioOutput::Task()
CommandFinished
();
continue
;
case
A
O_COMMAND_
CANCEL
:
case
A
udioOutputCommand
:
:
CANCEL
:
current_chunk
=
nullptr
;
if
(
open
)
{
...
...
@@ -667,7 +667,7 @@ AudioOutput::Task()
CommandFinished
();
continue
;
case
A
O_COMMAND_
KILL
:
case
A
udioOutputCommand
:
:
KILL
:
current_chunk
=
nullptr
;
CommandFinished
();
mutex
.
unlock
();
...
...
@@ -679,7 +679,7 @@ AudioOutput::Task()
chunks in the pipe */
continue
;
if
(
command
==
A
O_COMMAND_
NONE
)
{
if
(
command
==
A
udioOutputCommand
::
NONE
)
{
woken_for_play
=
false
;
cond
.
wait
(
mutex
);
}
...
...
@@ -696,7 +696,7 @@ AudioOutput::Task(void *arg)
void
AudioOutput
::
StartThread
()
{
assert
(
command
==
A
O_COMMAND_
NONE
);
assert
(
command
==
A
udioOutputCommand
::
NONE
);
Error
error
;
if
(
!
thread
.
Start
(
Task
,
this
,
error
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment