From: Nutchanon Wetchasit <Nutchanon.Wetchasit@gmail.com>
Subject: Fix build failure when "--disable-media" configure option was used.
Bug: https://savannah.gnu.org/bugs/?27952

This fixes the build failure part of bug #27952.
See <https://savannah.gnu.org/bugs/?27952>

diff --git a/libcore/asobj/NetStream_as.cpp b/libcore/asobj/NetStream_as.cpp
index 99d2a7a..d500ea0 100644
--- a/libcore/asobj/NetStream_as.cpp
+++ b/libcore/asobj/NetStream_as.cpp
@@ -1,7 +1,7 @@
 // NetStream.cpp:  ActionScript class for streaming audio/video, for Gnash.
 // 
-//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-//   Free Software Foundation, Inc
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
+//   2016 Free Software Foundation, Inc
 // 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -711,9 +711,10 @@ NetStream_as::decodeNextAudioFrame()
 #endif 
 
     raw->m_ptr = raw->m_data;
-#endif  // USE_MEDIA
-    
     return raw;
+#else   // USE_MEDIA
+    return nullptr;
+#endif
 }
 
 void
diff --git a/libcore/asobj/Sound_as.cpp b/libcore/asobj/Sound_as.cpp
index 4a6d11c..eddda73 100644
--- a/libcore/asobj/Sound_as.cpp
+++ b/libcore/asobj/Sound_as.cpp
@@ -1,6 +1,7 @@
 // Sound_as.cpp:  ActionScript "Sound" class, for Gnash.
 //
-//   Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+//   Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2016
+//   Free Software Foundation, Inc.
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -364,6 +365,7 @@ Sound_as::probeAudio()
 
     if (!_mediaParser) return; // nothing to do here w/out a media parser
 
+#ifdef USE_MEDIA
     if ( ! _soundLoaded ) {
 #ifdef GNASH_DEBUG_SOUND_AS
         log_debug("Probing audio for load");
@@ -441,6 +443,7 @@ Sound_as::probeAudio()
             assert(_audioDecoder.get());
         }
     }
+#endif  // USE_MEDIA
 #endif  // USE_SOUND
 }
 
@@ -810,12 +813,14 @@ Sound_as::getPosition() const
         return _soundHandler->tell(soundId);
     }
 
+#ifdef USE_MEDIA
     if (_mediaParser) {
         std::uint64_t ts;
         if ( _mediaParser->nextAudioFrameTimestamp(ts) ) {
             return ts;
         }
     }
+#endif  // USE_MEDIA
 #endif  // USE_SOUND
     
     return 0;
@@ -829,6 +834,7 @@ Sound_as::getAudio(std::int16_t* samples, unsigned int nSamples, bool& atEOF)
     int len = nSamples*2;
 
 #ifdef USE_SOUND
+#ifdef USE_MEDIA
     //GNASH_REPORT_FUNCTION;
 
     while (len) {
@@ -900,7 +906,12 @@ Sound_as::getAudio(std::int16_t* samples, unsigned int nSamples, bool& atEOF)
 
     atEOF=false;
     return nSamples-(len/2);
-#endif  // USE_SOUND
+#else   // USE_MEDIA
+    return 0;
+#endif
+#else   // USE_SOUND
+    return 0;
+#endif
 }
 
 // audio callback is running in sound handler thread
diff --git a/libmedia/MediaParser.cpp b/libmedia/MediaParser.cpp
index 7a7642d..8f40fb9 100644
--- a/libmedia/MediaParser.cpp
+++ b/libmedia/MediaParser.cpp
@@ -1,6 +1,6 @@
 // MediaParser.cpp:  Media file parser, for Gnash.
 //
-//   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+//   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016
 //   Free Software Foundation, Inc.
 //
 // This program is free software; you can redistribute it and/or modify
@@ -468,42 +468,6 @@ operator<< (std::ostream& os, const videoCodecType& t)
     return os;
 }
 
-std::ostream&
-operator<< (std::ostream& os, const audioCodecType& t)
-{
-    switch (t)
-    {
-        case AUDIO_CODEC_RAW:
-            os << "Raw";
-            break;
-        case AUDIO_CODEC_ADPCM:
-            os << "ADPCM";
-            break;
-        case AUDIO_CODEC_MP3:
-            os << "MP3";
-            break;
-        case AUDIO_CODEC_UNCOMPRESSED:
-            os << "Uncompressed";
-            break;
-        case AUDIO_CODEC_NELLYMOSER_8HZ_MONO:
-            os << "Nellymoser 8Hz mono";
-            break;
-        case AUDIO_CODEC_NELLYMOSER:
-            os << "Nellymoser";
-            break;
-        case AUDIO_CODEC_AAC:
-            os << "Advanced Audio Coding";
-            break;
-        case AUDIO_CODEC_SPEEX:
-            os << "Speex";
-            break;
-        default:
-            os << "unknown/invalid codec " << static_cast<int>(t);
-            break;
-    }
-    return os;
-}
-
 } // end of gnash::media namespace
 } // end of gnash namespace
 
diff --git a/libmedia/MediaParser.h b/libmedia/MediaParser.h
index e9f28c1..36520f1 100644
--- a/libmedia/MediaParser.h
+++ b/libmedia/MediaParser.h
@@ -1,6 +1,6 @@
 // MediaParser.h: Base class for media parsers
 // 
-//   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+//   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
 //   Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify
@@ -190,7 +190,41 @@ enum audioCodecType
 	//       also add them to the output operator!
 };
 
-DSOEXPORT std::ostream& operator<< (std::ostream& os, const audioCodecType& t);
+inline std::ostream&
+operator<< (std::ostream& os, const audioCodecType& t)
+{
+    switch (t)
+    {
+        case AUDIO_CODEC_RAW:
+            os << "Raw";
+            break;
+        case AUDIO_CODEC_ADPCM:
+            os << "ADPCM";
+            break;
+        case AUDIO_CODEC_MP3:
+            os << "MP3";
+            break;
+        case AUDIO_CODEC_UNCOMPRESSED:
+            os << "Uncompressed";
+            break;
+        case AUDIO_CODEC_NELLYMOSER_8HZ_MONO:
+            os << "Nellymoser 8Hz mono";
+            break;
+        case AUDIO_CODEC_NELLYMOSER:
+            os << "Nellymoser";
+            break;
+        case AUDIO_CODEC_AAC:
+            os << "Advanced Audio Coding";
+            break;
+        case AUDIO_CODEC_SPEEX:
+            os << "Speex";
+            break;
+        default:
+            os << "unknown/invalid codec " << static_cast<int>(t);
+            break;
+    }
+    return os;
+}
 
 /// Information about an audio stream 
 //
diff --git a/libsound/Makefile.am b/libsound/Makefile.am
index a771188..1d0e092 100644
--- a/libsound/Makefile.am
+++ b/libsound/Makefile.am
@@ -1,5 +1,5 @@
 # 
-#   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+#   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2016
 #    Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
@@ -73,8 +73,13 @@ libgnashsound_la_CPPFLAGS = \
 	$(SDL_CFLAGS) \
 	$(NULL)
 
-libgnashsound_la_LIBADD = \
-	$(top_builddir)/libmedia/libgnashmedia.la \
+if BUILD_LIBMEDIA
+libgnashsound_la_LIBADD = $(top_builddir)/libmedia/libgnashmedia.la
+else
+libgnashsound_la_LIBADD =
+endif
+
+libgnashsound_la_LIBADD += \
 	$(top_builddir)/libbase/libgnashbase.la \
 	$(BOOST_LIBS) \
 	$(SDL_LIBS) \
