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
c5409d52
Commit
c5409d52
authored
Dec 24, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/Internal: move enum AudioOutputCommand into the struct
parent
54fc8f0e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
58 deletions
+58
-58
Init.cxx
src/output/Init.cxx
+1
-1
Internal.hxx
src/output/Internal.hxx
+26
-26
OutputControl.cxx
src/output/OutputControl.cxx
+13
-13
OutputThread.cxx
src/output/OutputThread.cxx
+18
-18
No files found.
src/output/Init.cxx
View file @
c5409d52
...
@@ -58,7 +58,7 @@ AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin)
...
@@ -58,7 +58,7 @@ AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin)
filter
(
nullptr
),
filter
(
nullptr
),
replay_gain_filter
(
nullptr
),
replay_gain_filter
(
nullptr
),
other_replay_gain_filter
(
nullptr
),
other_replay_gain_filter
(
nullptr
),
command
(
AudioOutput
Command
::
NONE
)
command
(
Command
::
NONE
)
{
{
assert
(
plugin
.
finish
!=
nullptr
);
assert
(
plugin
.
finish
!=
nullptr
);
assert
(
plugin
.
open
!=
nullptr
);
assert
(
plugin
.
open
!=
nullptr
);
...
...
src/output/Internal.hxx
View file @
c5409d52
...
@@ -40,32 +40,32 @@ struct config_param;
...
@@ -40,32 +40,32 @@ struct config_param;
struct
PlayerControl
;
struct
PlayerControl
;
struct
AudioOutputPlugin
;
struct
AudioOutputPlugin
;
enum
class
AudioOutputCommand
{
struct
AudioOutput
{
NONE
,
enum
class
Command
{
ENABLE
,
NONE
,
DISABLE
,
ENABLE
,
OPEN
,
DISABLE
,
OPEN
,
/**
/**
* This command is invoked when the input audio format
* This command is invoked when the input audio format
* changes.
* changes.
*/
*/
REOPEN
,
REOPEN
,
CLOSE
,
CLOSE
,
PAUSE
,
PAUSE
,
/**
/**
* Drains the internal (hardware) buffers of the device. This
* Drains the internal (hardware) buffers of the device. This
* operation may take a while to complete.
* operation may take a while to complete.
*/
*/
DRAIN
,
DRAIN
,
CANCEL
,
CANCEL
,
KILL
KILL
};
};
struct
AudioOutput
{
/**
/**
* The device's configured display name.
* The device's configured display name.
*/
*/
...
@@ -231,7 +231,7 @@ struct AudioOutput {
...
@@ -231,7 +231,7 @@ struct AudioOutput {
/**
/**
* The next command to be performed by the output thread.
* The next command to be performed by the output thread.
*/
*/
AudioOutput
Command
command
;
Command
command
;
/**
/**
* The music pipe which provides music chunks to be played.
* The music pipe which provides music chunks to be played.
...
@@ -284,7 +284,7 @@ struct AudioOutput {
...
@@ -284,7 +284,7 @@ struct AudioOutput {
}
}
bool
IsCommandFinished
()
const
{
bool
IsCommandFinished
()
const
{
return
command
==
AudioOutput
Command
::
NONE
;
return
command
==
Command
::
NONE
;
}
}
/**
/**
...
@@ -299,7 +299,7 @@ struct AudioOutput {
...
@@ -299,7 +299,7 @@ struct AudioOutput {
*
*
* Caller must lock the mutex.
* Caller must lock the mutex.
*/
*/
void
CommandAsync
(
AudioOutput
Command
cmd
);
void
CommandAsync
(
Command
cmd
);
/**
/**
* Sends a command to the #AudioOutput object and waits for
* Sends a command to the #AudioOutput object and waits for
...
@@ -307,13 +307,13 @@ struct AudioOutput {
...
@@ -307,13 +307,13 @@ struct AudioOutput {
*
*
* Caller must lock the mutex.
* Caller must lock the mutex.
*/
*/
void
CommandWait
(
AudioOutput
Command
cmd
);
void
CommandWait
(
Command
cmd
);
/**
/**
* Lock the #AudioOutput object and execute the command
* Lock the #AudioOutput object and execute the command
* synchronously.
* synchronously.
*/
*/
void
LockCommandWait
(
AudioOutput
Command
cmd
);
void
LockCommandWait
(
Command
cmd
);
/**
/**
* Enables the device.
* Enables the device.
...
...
src/output/OutputControl.cxx
View file @
c5409d52
...
@@ -46,7 +46,7 @@ AudioOutput::WaitForCommand()
...
@@ -46,7 +46,7 @@ AudioOutput::WaitForCommand()
}
}
void
void
AudioOutput
::
CommandAsync
(
AudioOutput
Command
cmd
)
AudioOutput
::
CommandAsync
(
Command
cmd
)
{
{
assert
(
IsCommandFinished
());
assert
(
IsCommandFinished
());
...
@@ -55,14 +55,14 @@ AudioOutput::CommandAsync(AudioOutputCommand cmd)
...
@@ -55,14 +55,14 @@ AudioOutput::CommandAsync(AudioOutputCommand cmd)
}
}
void
void
AudioOutput
::
CommandWait
(
AudioOutput
Command
cmd
)
AudioOutput
::
CommandWait
(
Command
cmd
)
{
{
CommandAsync
(
cmd
);
CommandAsync
(
cmd
);
WaitForCommand
();
WaitForCommand
();
}
}
void
void
AudioOutput
::
LockCommandWait
(
AudioOutput
Command
cmd
)
AudioOutput
::
LockCommandWait
(
Command
cmd
)
{
{
const
ScopeLock
protect
(
mutex
);
const
ScopeLock
protect
(
mutex
);
CommandWait
(
cmd
);
CommandWait
(
cmd
);
...
@@ -92,7 +92,7 @@ AudioOutput::LockEnableWait()
...
@@ -92,7 +92,7 @@ AudioOutput::LockEnableWait()
StartThread
();
StartThread
();
}
}
LockCommandWait
(
AudioOutput
Command
::
ENABLE
);
LockCommandWait
(
Command
::
ENABLE
);
}
}
void
void
...
@@ -109,7 +109,7 @@ AudioOutput::LockDisableWait()
...
@@ -109,7 +109,7 @@ AudioOutput::LockDisableWait()
return
;
return
;
}
}
LockCommandWait
(
AudioOutput
Command
::
DISABLE
);
LockCommandWait
(
Command
::
DISABLE
);
}
}
inline
bool
inline
bool
...
@@ -134,7 +134,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
...
@@ -134,7 +134,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
/* we're not using audio_output_cancel() here,
/* we're not using audio_output_cancel() here,
because that function is asynchronous */
because that function is asynchronous */
CommandWait
(
AudioOutput
Command
::
CANCEL
);
CommandWait
(
Command
::
CANCEL
);
}
}
return
true
;
return
true
;
...
@@ -149,8 +149,8 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
...
@@ -149,8 +149,8 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
StartThread
();
StartThread
();
CommandWait
(
open
CommandWait
(
open
?
AudioOutput
Command
::
REOPEN
?
Command
::
REOPEN
:
AudioOutput
Command
::
OPEN
);
:
Command
::
OPEN
);
const
bool
open2
=
open
;
const
bool
open2
=
open
;
if
(
open2
&&
mixer
!=
nullptr
)
{
if
(
open2
&&
mixer
!=
nullptr
)
{
...
@@ -174,7 +174,7 @@ AudioOutput::CloseWait()
...
@@ -174,7 +174,7 @@ AudioOutput::CloseWait()
assert
(
!
open
||
!
fail_timer
.
IsDefined
());
assert
(
!
open
||
!
fail_timer
.
IsDefined
());
if
(
open
)
if
(
open
)
CommandWait
(
AudioOutput
Command
::
CLOSE
);
CommandWait
(
Command
::
CLOSE
);
else
else
fail_timer
.
Reset
();
fail_timer
.
Reset
();
}
}
...
@@ -221,7 +221,7 @@ AudioOutput::LockPauseAsync()
...
@@ -221,7 +221,7 @@ AudioOutput::LockPauseAsync()
assert
(
allow_play
);
assert
(
allow_play
);
if
(
IsOpen
())
if
(
IsOpen
())
CommandAsync
(
AudioOutput
Command
::
PAUSE
);
CommandAsync
(
Command
::
PAUSE
);
}
}
void
void
...
@@ -231,7 +231,7 @@ AudioOutput::LockDrainAsync()
...
@@ -231,7 +231,7 @@ AudioOutput::LockDrainAsync()
assert
(
allow_play
);
assert
(
allow_play
);
if
(
IsOpen
())
if
(
IsOpen
())
CommandAsync
(
AudioOutput
Command
::
DRAIN
);
CommandAsync
(
Command
::
DRAIN
);
}
}
void
void
...
@@ -241,7 +241,7 @@ AudioOutput::LockCancelAsync()
...
@@ -241,7 +241,7 @@ AudioOutput::LockCancelAsync()
if
(
IsOpen
())
{
if
(
IsOpen
())
{
allow_play
=
false
;
allow_play
=
false
;
CommandAsync
(
AudioOutput
Command
::
CANCEL
);
CommandAsync
(
Command
::
CANCEL
);
}
}
}
}
...
@@ -279,7 +279,7 @@ AudioOutput::StopThread()
...
@@ -279,7 +279,7 @@ AudioOutput::StopThread()
assert
(
thread
.
IsDefined
());
assert
(
thread
.
IsDefined
());
assert
(
allow_play
);
assert
(
allow_play
);
LockCommandWait
(
AudioOutput
Command
::
KILL
);
LockCommandWait
(
Command
::
KILL
);
thread
.
Join
();
thread
.
Join
();
}
}
...
...
src/output/OutputThread.cxx
View file @
c5409d52
...
@@ -45,8 +45,8 @@
...
@@ -45,8 +45,8 @@
void
void
AudioOutput
::
CommandFinished
()
AudioOutput
::
CommandFinished
()
{
{
assert
(
command
!=
AudioOutput
Command
::
NONE
);
assert
(
command
!=
Command
::
NONE
);
command
=
AudioOutput
Command
::
NONE
;
command
=
Command
::
NONE
;
mutex
.
unlock
();
mutex
.
unlock
();
audio_output_client_notify
.
Signal
();
audio_output_client_notify
.
Signal
();
...
@@ -342,7 +342,7 @@ AudioOutput::WaitForDelay()
...
@@ -342,7 +342,7 @@ AudioOutput::WaitForDelay()
(
void
)
cond
.
timed_wait
(
mutex
,
delay
);
(
void
)
cond
.
timed_wait
(
mutex
,
delay
);
if
(
command
!=
AudioOutput
Command
::
NONE
)
if
(
command
!=
Command
::
NONE
)
return
false
;
return
false
;
}
}
}
}
...
@@ -471,7 +471,7 @@ AudioOutput::PlayChunk(const MusicChunk *chunk)
...
@@ -471,7 +471,7 @@ AudioOutput::PlayChunk(const MusicChunk *chunk)
Error
error
;
Error
error
;
while
(
!
data
.
IsEmpty
()
&&
command
==
AudioOutput
Command
::
NONE
)
{
while
(
!
data
.
IsEmpty
()
&&
command
==
Command
::
NONE
)
{
if
(
!
WaitForDelay
())
if
(
!
WaitForDelay
())
break
;
break
;
...
@@ -529,7 +529,7 @@ AudioOutput::Play()
...
@@ -529,7 +529,7 @@ AudioOutput::Play()
assert
(
!
in_playback_loop
);
assert
(
!
in_playback_loop
);
in_playback_loop
=
true
;
in_playback_loop
=
true
;
while
(
chunk
!=
nullptr
&&
command
==
AudioOutput
Command
::
NONE
)
{
while
(
chunk
!=
nullptr
&&
command
==
Command
::
NONE
)
{
assert
(
!
current_chunk_finished
);
assert
(
!
current_chunk_finished
);
current_chunk
=
chunk
;
current_chunk
=
chunk
;
...
@@ -577,7 +577,7 @@ AudioOutput::Pause()
...
@@ -577,7 +577,7 @@ AudioOutput::Pause()
Close
(
false
);
Close
(
false
);
break
;
break
;
}
}
}
while
(
command
==
AudioOutput
Command
::
NONE
);
}
while
(
command
==
Command
::
NONE
);
pause
=
false
;
pause
=
false
;
}
}
...
@@ -594,30 +594,30 @@ AudioOutput::Task()
...
@@ -594,30 +594,30 @@ AudioOutput::Task()
while
(
1
)
{
while
(
1
)
{
switch
(
command
)
{
switch
(
command
)
{
case
AudioOutput
Command
:
:
NONE
:
case
Command
:
:
NONE
:
break
;
break
;
case
AudioOutput
Command
:
:
ENABLE
:
case
Command
:
:
ENABLE
:
Enable
();
Enable
();
CommandFinished
();
CommandFinished
();
break
;
break
;
case
AudioOutput
Command
:
:
DISABLE
:
case
Command
:
:
DISABLE
:
Disable
();
Disable
();
CommandFinished
();
CommandFinished
();
break
;
break
;
case
AudioOutput
Command
:
:
OPEN
:
case
Command
:
:
OPEN
:
Open
();
Open
();
CommandFinished
();
CommandFinished
();
break
;
break
;
case
AudioOutput
Command
:
:
REOPEN
:
case
Command
:
:
REOPEN
:
Reopen
();
Reopen
();
CommandFinished
();
CommandFinished
();
break
;
break
;
case
AudioOutput
Command
:
:
CLOSE
:
case
Command
:
:
CLOSE
:
assert
(
open
);
assert
(
open
);
assert
(
pipe
!=
nullptr
);
assert
(
pipe
!=
nullptr
);
...
@@ -625,7 +625,7 @@ AudioOutput::Task()
...
@@ -625,7 +625,7 @@ AudioOutput::Task()
CommandFinished
();
CommandFinished
();
break
;
break
;
case
AudioOutput
Command
:
:
PAUSE
:
case
Command
:
:
PAUSE
:
if
(
!
open
)
{
if
(
!
open
)
{
/* the output has failed after
/* the output has failed after
audio_output_all_pause() has
audio_output_all_pause() has
...
@@ -642,7 +642,7 @@ AudioOutput::Task()
...
@@ -642,7 +642,7 @@ AudioOutput::Task()
the new command first */
the new command first */
continue
;
continue
;
case
AudioOutput
Command
:
:
DRAIN
:
case
Command
:
:
DRAIN
:
if
(
open
)
{
if
(
open
)
{
assert
(
current_chunk
==
nullptr
);
assert
(
current_chunk
==
nullptr
);
assert
(
pipe
->
Peek
()
==
nullptr
);
assert
(
pipe
->
Peek
()
==
nullptr
);
...
@@ -655,7 +655,7 @@ AudioOutput::Task()
...
@@ -655,7 +655,7 @@ AudioOutput::Task()
CommandFinished
();
CommandFinished
();
continue
;
continue
;
case
AudioOutput
Command
:
:
CANCEL
:
case
Command
:
:
CANCEL
:
current_chunk
=
nullptr
;
current_chunk
=
nullptr
;
if
(
open
)
{
if
(
open
)
{
...
@@ -667,7 +667,7 @@ AudioOutput::Task()
...
@@ -667,7 +667,7 @@ AudioOutput::Task()
CommandFinished
();
CommandFinished
();
continue
;
continue
;
case
AudioOutput
Command
:
:
KILL
:
case
Command
:
:
KILL
:
current_chunk
=
nullptr
;
current_chunk
=
nullptr
;
CommandFinished
();
CommandFinished
();
mutex
.
unlock
();
mutex
.
unlock
();
...
@@ -679,7 +679,7 @@ AudioOutput::Task()
...
@@ -679,7 +679,7 @@ AudioOutput::Task()
chunks in the pipe */
chunks in the pipe */
continue
;
continue
;
if
(
command
==
AudioOutput
Command
::
NONE
)
{
if
(
command
==
Command
::
NONE
)
{
woken_for_play
=
false
;
woken_for_play
=
false
;
cond
.
wait
(
mutex
);
cond
.
wait
(
mutex
);
}
}
...
@@ -696,7 +696,7 @@ AudioOutput::Task(void *arg)
...
@@ -696,7 +696,7 @@ AudioOutput::Task(void *arg)
void
void
AudioOutput
::
StartThread
()
AudioOutput
::
StartThread
()
{
{
assert
(
command
==
AudioOutput
Command
::
NONE
);
assert
(
command
==
Command
::
NONE
);
Error
error
;
Error
error
;
if
(
!
thread
.
Start
(
Task
,
this
,
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